package cn.udrm.water.base.v1.waterdelivery.entities;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedAttributeNode;
import javax.persistence.NamedEntityGraph;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 渠道进水口(渠道直开口)
 * 刘康、赵磊、董智进行讨论
 * 意见 1：以渠道为主，一个渠道包含多个出水口（斗口、直开口、引水口等），由该实体保存渠道关系 1：n
 * 意见 2：一个渠道含有一个进水口，由渠道保存该实体关系 1：1
 * 结果：选取意见2，方便进行水量计算统计；但是要获取某条渠的所有直开口，需要进行多次查询
 * @author liukang
 * @date 2019年1月31日
 */
@Getter
@Setter
@NoArgsConstructor
@Entity(name="CanalSystemInTake")
@Table(name="T_CANAL_SYSTEM_IN_TAKE")
@NamedEntityGraph(name="CanalSystemInTake.canalSystem",
	attributeNodes={
		@NamedAttributeNode("canalSystem")
})
public class CanalSystemInTake {

	@Id
	@GenericGenerator(name="idGenerator", strategy="uuid")
	@GeneratedValue(generator="idGenerator")
	@Column(name="ID")
	private String id;
	/*
	 * 系统编码
	 */
	@Column(name="ENTITY_CODE")
	private String entityCode;
	@Column(name="CREATE_DATE")
	private Date createDate;
	@Column(name="PERSON_GUID")
	private String personGuid;
	@Column(name="PERSON_NAME")
	private String personName;
	/*
	 * 桩号
	 */
	@Column(name="MILEAGE")
	private String mileage;
	/*
	 * 名称
	 */
	@Column(name="NAME")
	private String name;
	
	@OneToOne(optional=true, fetch=FetchType.LAZY)
	@JoinColumn(name="CANAL_SYSTEM_GUID")
	private CanalSystem canalSystem;
	
	public CanalSystemInTake(String id) {
		this.id = id;
	}
}
